Skip to content

Make gaus_2d faster#273

Merged
gmloose merged 3 commits intolofar-astron:masterfrom
AlexKurek:Make-`gaus_2d`-faster
May 1, 2026
Merged

Make gaus_2d faster#273
gmloose merged 3 commits intolofar-astron:masterfrom
AlexKurek:Make-`gaus_2d`-faster

Conversation

@AlexKurek
Copy link
Copy Markdown
Contributor

@AlexKurek AlexKurek commented Apr 28, 2026

On a 127 MB, 5762*5762 image, atrous_do = True. Python 3.13, Numpy 2.4.
tottime and cumtime are noticeably shorter.

before:
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    10934    0.235    0.000    0.239    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10934    0.240    0.000    0.244    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10934    0.253    0.000    0.257    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10934    0.241    0.000    0.244    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)

after:
    10935    0.200    0.000    0.204    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10935    0.205    0.000    0.208    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10935    0.222    0.000    0.226    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)
    10935    0.196    0.000    0.200    0.000 /home/akurek/miniconda3/envs/pybdsf-313_local_temp/lib/python3.13/site-packages/bdsf/[functions.py:202](http://functions.py:202/)(gaus_2d)

NGC6048_9-MFS-image.pybdsf.gaul files are identical.

Comment thread bdsf/functions.py
Comment thread bdsf/functions.py Outdated
Comment thread bdsf/functions.py Outdated
Comment on lines +222 to +223
inv_sigx2 = 0.5 / (c[3]**2)
inv_sigy2 = 0.5 / (c[4]**2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor nit-pick. Since you're going to need the negative value of these to calculate the exponent, would it not make sense to use -0.5 here already. It makes line 233 feel a bit more logic: ... N.exp(exponent), instead of ... N.exp(-exponent).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, changed. Benchamarking and .gaul file still are looking good.

@gmloose gmloose merged commit 0de6150 into lofar-astron:master May 1, 2026
1 check passed
@AlexKurek AlexKurek deleted the Make-`gaus_2d`-faster branch May 1, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants